#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 6e5 + 5;
const int K = 25;

int n, m;
int a[N];
struct Node {
  int sz;
  int ch[2];
} tr[N * K];
int rt[N];
int newnode(int p) {
  static int tot = 0;
  ++tot;
  tr[tot].sz = tr[p].sz + 1;
  tr[tot].ch[0] = tr[p].ch[0];
  tr[tot].ch[1] = tr[p].ch[1];
  return tot;
}
int insert(int rt, int x) {
  rt = newnode(rt);
  int p = rt;
  per(i, K, 0) {
    int c = x >> i & 1;
    tr[p].ch[c] = newnode(tr[p].ch[c]);
    p = tr[p].ch[c];
  }
  return rt;
}
int query1(int p, int x) {
  int ans = 0;
  per(i, K, 0) {
    int c = (x >> i & 1) ^ 1;
    if (tr[p].ch[c])
      ans |= 1 << i;
    else
      c ^= 1;
    p = tr[p].ch[c];
  }
  return ans;
}
int query2(int p1, int p2, int x) {
  int ans = 0;
  per(i, K, 0) {
    int c = (x >> i & 1) ^ 1;
    if (tr[tr[p2].ch[c]].sz > tr[tr[p1].ch[c]].sz)
      ans |= 1 << i;
    else
      c ^= 1;
    p1 = tr[p1].ch[c], p2 = tr[p2].ch[c];
  }
  return ans;
}
int query(int l, int r, int x) {
  x ^= a[n];
  if (l == r) return a[r - 1] ^ x;
  // a[p - 1] ^ a[r] ^ x, p in [l, r]
  else if (l == 1)
    return query1(rt[r - 1], x);
  else
    return query2(rt[l - 2], rt[r - 1], x);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rt[0] = insert(0, 0);
  rep(i, 1, n) {
    cin >> a[i];
    a[i] ^= a[i - 1];
    rt[i] = insert(rt[i - 1], a[i]);
  }
  while (m--) {
    char op;
    int x, y, z;
    cin >> op;
    if (op == 'Q') {
      cin >> x >> y >> z;
      cout << query(x, y, z) << endl;
    } else {
      ++n;
      cin >> a[n];
      a[n] ^= a[n - 1];
      rt[n] = insert(rt[n - 1], a[n]);
    }
  }
  return 0;
}